//
// Created by kaifa01 on 2021/6/9.
//

#ifndef C_STUDY_FILE_H
#define C_STUDY_FILE_H

void file_write() {
    FILE *fp;
    char str[] = "This is test";

    fp = fopen( "file.txt" , "w" );
    fwrite(str, sizeof(str) , 1, fp );

    fclose(fp);
}

void file_open() {
    FILE *fp;
    int c;

    fp = fopen("file.txt","r");
    while(1)
    {
        c = fgetc(fp);
        if( feof(fp) )
        {
            break ;
        }
        printf("%c", c);
    }
    fclose(fp);
}

#endif //C_STUDY_FILE_H
